
<?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date') ?>
<title><?= $sf_response->getTitle() ?></title>
<?php use_stylesheet('/sf/sf_admin/css/main') ?>

<div id="sf_admin_container">

<h1>View <?php echo $mr3->getMrno() ?></h1>

<div id="sf_admin_content">

<fieldset id="sf_fieldset_none" class="">

<div class="form-row">
  <?php echo label_for('mr3[mrno]', __($labels['mr3{mrno}']), 'class="required" ') ?>
  <div class="content<?php if ($sf_request->hasError('mr3{mrno}')): ?> form-error<?php endif; ?>">
  <?php if ($sf_request->hasError('mr3{mrno}')): ?>
    <?php echo form_error('mr3{mrno}', array('class' => 'form-error-msg')) ?>
  <?php endif; ?>

 <!--Tien code here-->
  <?php $default = CommonValues::GenerateAutoNumber('MR3', $mr3->getMrno(), 'MRRAW')   ?>
   <input name="mr3[mrno]" id="mr3_mrno" value="<?php echo $default ?>"  type="hidden">
   <input name="mr2_mrno_show" id="mr2_mrno_show" value="<?php echo $default ?>" size="15" disabled="disabled" type="text">
   </div>
</div>

<div class="form-row">
  <?php echo label_for('mr3[category]', __($labels['mr3{category}']), '') ?>
  <div class="content<?php if ($sf_request->hasError('mr3{category}')): ?> form-error<?php endif; ?>">
  <?php if ($sf_request->hasError('mr3{category}')): ?>
    <?php echo form_error('mr3{category}', array('class' => 'form-error-msg')) ?>
  <?php endif; ?>

  <input type="hidden" name = "mr3[category]" id ="mr3_category" value="<?php echo CommonValues::$gMRCategory['key']['Stock']?>"/>
  <input type="text" name = "mr3_show_category" id ="mr3_show_category" disabled = "1" size = "5" value="Stock"/>
    </div>
</div>

<div class="form-row">
  <?php echo label_for('mr3[reqarrdate]', __($labels['mr3{reqarrdate}']), '') ?>
  <div class="content<?php if ($sf_request->hasError('mr3{reqarrdate}')): ?> form-error<?php endif; ?>">
  <?php if ($sf_request->hasError('mr3{reqarrdate}')): ?>
    <?php echo form_error('mr3{reqarrdate}', array('class' => 'form-error-msg')) ?>
  <?php endif; ?>

  <?php $value = object_input_date_tag($mr3, 'getReqarrdate', array (
  'rich' => true,
  'calendar_button_img' => '/sf/sf_admin/images/date.png',
  'control_name' => 'mr3[reqarrdate]',
  'disabled'=>1,
)); echo $value ? $value : '&nbsp;' ?>
    </div>
</div>


<div class="form-row">
  <?php echo label_for('mr3[status]', __($labels['mr3{status}']), '') ?>
  <div class="content<?php if ($sf_request->hasError('mr3{status}')): ?> form-error<?php endif; ?>">
  <?php if ($sf_request->hasError('mr3{status}')): ?>
    <?php echo form_error('mr3{status}', array('class' => 'form-error-msg')) ?>
  <?php endif; ?>

  <?php  $status = $mr3->getStatus()?  $mr3->getStatus(): 0?> 
  <input type="text" name ="mr_show" id ="mr_show" disabled="1"  value="<?php echo CommonValues::$gMRStatus['value'][$status]?>">
  <input type="hidden" name ="mr3[status]" id ="mr3_status" value="<?php echo $status?>">
    </div>
</div>

<div class="form-row">
  <?php echo label_for('mr3[approvalstatus]', __($labels['mr3{approvalstatus}']), '') ?>
  <div class="content<?php if ($sf_request->hasError('mr3{approvalstatus}')): ?> form-error<?php endif; ?>">
  <?php if ($sf_request->hasError('mr3{approvalstatus}')): ?>
    <?php echo form_error('mr3{approvalstatus}', array('class' => 'form-error-msg')) ?>
  <?php endif; ?>

  <?php  $status = $mr3->getApprovalstatus()?  $mr3->getApprovalstatus(): 0?> 
  <input type="text" name ="mr_show" id ="mr_show" disabled="1"  value="<?php echo CommonValues::$gMRApprovalStatus['value'][$status]?>">
  <input type="hidden" name ="mr3[approvalstatus]" id ="mr3_approvalstatus" value="<?php echo $status?>">
    </div>
</div>


</fieldset>

<!--Tien code here
get information for MR-->
<?php
    if ($mr3->getComponentgroupId()){
        $componentGroupId = $mr3->getComponentgroupId();
        
        $c = new Criteria();
        $c->add(ComponentsPeer::COMPONENTGROUP_ID , $componentGroupId);
        $c->addAscendingOrderByColumn(ComponentsPeer::ID);
        
        $componentList = ComponentsPeer::doSelect($c);
    }
?>

<table id ='added_components' "cellspacing="0" class="sf_admin_list">
<thead>
<tr>
      <th id="sf_admin_list_th_productcode" width="25%">Product Code </th>
      <th id="sf_admin_list_th_description" width="45%">Description</th>
      <th id="sf_admin_list_th_description" width="10%">Brand</th>       
      <th id="sf_admin_list_th_description" width="5%">Unit
              </th>
      <th id="sf_admin_list_th_description" width="10%">Expected Delivery Date (YYYY-MM-DD)</th>
      
      <th id="sf_admin_list_th_description">Qty to request</th>
</tr>
</thead>
<!--show component here-->
<?php if (isset($componentList) && $componentList) {
    foreach ($componentList as $key=>$components) { 
        $component1= ComponentPeer::retrieveByPK($components->getComponentId());
        ?>
        <tr class="sf_admin_row_<?php echo $key%2?>">
            <input type="hidden" name="rowIds[]" id ="rowIds"  class = "ExistComponents" value="<? echo $component1->getId()?>"/>
            <td><?echo $component1->getProductcode()?></td>
            <td><?echo $component1->getDescription()?></td>
            <td><?echo $component1->getBrand()?></td>
            <td><?echo $component1->getComponentunit()?></td>
            <td><?echo $components->getDate()?></td>
            <td><input type="text" name="qtys[]" id ="qtys" disabled size="5" class="QTYS"  value ="<?echo $components->getQty1()?>"></td>
            
        </tr>
<?php } }?>
</table>
<ul class="sf_admin_actions">
  <li><?php echo button_to(__('Approve'), 'approval/ApproveObject?authenticationMain=APPROVE_MRRAW&authenticationSub=PR_APPROVE_MRRAW&mod=MRRAW&id='.$mr3->getId().'&backURL=approval~1ListApprovalObject~2authenticationMain~4APPROVE_MRRAW~3authenticationSub~4PR_APPROVE_MRRAW~3mod~4MRRAW~3backURL~4', array (
  'class' => 'sf_admin_action_approve',
  'confirm' => __('Are you sure you want to approve this MR?'),
)) ?></li>
  <li><?php echo button_to(__('Reject'), 'approval/RejectObject?authenticationMain=APPROVE_MRRAW&authenticationSub=PR_APPROVE_MRRAW&mod=MRRAW&id='.$mr3->getId().'&backURL=approval~1ListApprovalObject~2authenticationMain~4APPROVE_MRRAW~3authenticationSub~4PR_APPROVE_MRRAW~3mod~4MRRAW~3backURL~4', array (
  'class' => 'sf_admin_action_reject',
)) ?></li>
    </ul>
</div>

</div>
